package com.elong.businesstravel.protocol.hotel;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.Header;
import org.apache.http.client.HttpResponseException;
import org.json.JSONArray;
import org.json.JSONObject;

import com.elong.businesstravel.entitys.HotelReviews;
import com.elong.businesstravel.protocol.baseresponse.BaseELongJsonHttpResponse;

public class GetHotelReviewsResponse extends BaseELongJsonHttpResponse {

	public List<HotelReviews> hotelReviews = new ArrayList<HotelReviews>();

	@Override
	public void onSuccess(int statusCode, Header[] headers,
			JSONObject mainJsonObject) throws Throwable {
		JSONObject responseJsonObject = mainJsonObject
				.optJSONObject("response");
		JSONArray detailJsonArray = responseJsonObject.optJSONArray("detail");
		if (null != detailJsonArray) {
			for (int i = 0; i < detailJsonArray.length(); i++) {
				JSONObject itemDetailJsonObject = detailJsonArray
						.getJSONObject(i);
				if (null != itemDetailJsonObject) {
					HotelReviews hotelReviews = new HotelReviews();
					hotelReviews.adddate = itemDetailJsonObject.optString(
							"adddate", "");
					hotelReviews.content = itemDetailJsonObject.optString(
							"content", "");
					hotelReviews.guest_name = itemDetailJsonObject.optString(
							"guest_name", "");
					hotelReviews.RecommendType = itemDetailJsonObject
							.optString("RecommendType", "");
					hotelReviews.voicetime = itemDetailJsonObject.optString("voicetime","");
					hotelReviews.voiceurl = itemDetailJsonObject.optString("voiceurl","");
					this.hotelReviews.add(hotelReviews);
				}
			}
		}
	}

}
